package com.baidu.mpks.statistic.meta;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Objects;

public class ClickRatioCount implements Serializable {
    @Setter
    @Getter
    private String date;
    @Setter
    @Getter
    private long click;
    @Setter
    @Getter
    private long total;
    @Setter
    @Getter
    private float ratio;

    public ClickRatioCount() {
    }

    public ClickRatioCount(String date, long click, long total) {
        this.date = date;
        this.click = click;
        this.total = total;
        this.ratio = (float) click / total;
    }

    @Override
    public String toString() {
        return "{" +
                "\"date\":\"" + date + "\"," +
                "\"click:\"" + click + "\"," +
                "\"total:\"" + total + "\"," +
                "\"ratio:\"" + ratio + "\"" +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ClickRatioCount)) {
            return false;
        }
        ClickRatioCount count = (ClickRatioCount) o;
        return date.equals(count.date);
    }

    @Override
    public int hashCode() {
        return Objects.hash(date);
    }
}
